import rxAjax from '@/assets/js/ajax.js';
import FormUtil from "@/assets/js/FormUtil";

//空项目代码生成表 api接口
export const FormCodegenProjectApi = {};

FormCodegenProjectApi.baseUrl= '/api-form/form/codegen/formCodegenProject';
FormCodegenProjectApi.exportUrl= FormCodegenProjectApi.baseUrl + '/listExport';

//查询列表
FormCodegenProjectApi.query=function (parameter) {
  var url= FormCodegenProjectApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
FormCodegenProjectApi.get =function(pkId) {
  var url= FormCodegenProjectApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
FormCodegenProjectApi.save =function(parameter) {
  var url= FormCodegenProjectApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
FormCodegenProjectApi.del =function(parameter) {
  var url= FormCodegenProjectApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

FormCodegenProjectApi.genCode=function(pkId){
  var url = FormCodegenProjectApi.baseUrl + '/genCode';
  return FormUtil.doExport(url,{pkId:pkId});
}
//变更分类
FormCodegenProjectApi.changeCategory=function(ids,categoryId){
    var url= FormCodegenProjectApi.baseUrl+'/changeCategory';
    return rxAjax.postForm(url, {ids:ids,categoryId:categoryId});
}

export  default FormCodegenProjectApi;

